package com.chengyu.core.controller.member;

import com.chengyu.core.component.OperationLog;
import com.chengyu.core.controller.UserBaseController;
import com.chengyu.core.domain.CommonConstant;
import com.chengyu.core.domain.form.AccountSearchForm;
import com.chengyu.core.entity.CommonPage;
import com.chengyu.core.entity.CommonResult;
import com.chengyu.core.exception.ServiceException;
import com.chengyu.core.mapper.UmsMemberThirdAccountMapper;
import com.chengyu.core.model.UmsMemberAccountLog;
import com.chengyu.core.model.UmsMemberThirdAccount;
import com.chengyu.core.service.funds.MemberAccountLogService;
import com.chengyu.core.service.member.MemberThirdAccountService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * @author LeGreen
 * @title 会员绑定给第三方账号
 * @date 2024/3/6
 */
@Api(tags = "会员绑定给第三方账号")
@Controller
@RequestMapping("/member")
public class MemberThirdAccountController extends UserBaseController {

    @Autowired
    private MemberThirdAccountService memberThirdAccountService;

    @ApiOperation(value = "获取列表")
    @ResponseBody
    @RequestMapping(value = "/thirdAccount/getList", method = RequestMethod.GET)
    public CommonResult<CommonPage<UmsMemberThirdAccount>> getList(Integer type, Integer page, Integer pageSize) throws ServiceException {

        List<UmsMemberThirdAccount> list = memberThirdAccountService.getList(getCurrentMemberId(), type, page, pageSize);
        return CommonResult.success(CommonPage.restPage(list));
    }


    @ApiOperation(value = "删除")
    @ResponseBody
    @RequestMapping(value = "/thirdAccount/delete", method = RequestMethod.POST)
    public CommonResult<String> delete(Integer id) {
        if (id == null) {
            return CommonResult.failed("id不能为空");
        }
        memberThirdAccountService.delete(id);
        return CommonResult.success(null);
    }

    @ApiOperation(value = "根据会员号查看所有的第三方账号")
    @ResponseBody
    @RequestMapping(value = "/thirdAccount/selectThirdAccountByMemberId", method = RequestMethod.GET)
    public CommonResult<List<UmsMemberThirdAccount>> selectThirdAccountByMemberId() throws ServiceException {

        List<UmsMemberThirdAccount> list = memberThirdAccountService.selectThirdAccountByMemberId(getCurrentMemberId());
        return CommonResult.success(list);
    }
}